//
//  DingDanZhanShiFooterView.m
//  NBProduct
//
//  Created by ping on 15/11/13.
//  Copyright (c) 2015年 ping. All rights reserved.
//

#import "DingDanZhanShiFooterView.h"
#import "ZhiFuViewFangShiBtn.h"
#import "BaseViewController.h"
@implementation DingDanZhanShiFooterView
{
    int _weiXinZhuangTai;
}

-(instancetype)initWithFrame:(CGRect)frame{
    self = [super initWithFrame:frame];
    if (self) {
        _weiXinZhuangTai = 0;
        _height = 50 * _kscH;
        _zhifuFangShiBJ = 0;
        _btnAry = [[NSMutableArray alloc]init];
        [self initView];
    }
    
    return self;
}

-(instancetype)initWithFrame:(CGRect)frame andShiFouWX:(int)WeiXinZhuangTai{
    self = [super initWithFrame:frame];
    if (self) {
        _weiXinZhuangTai = WeiXinZhuangTai;
        _height = 50 * _kscH;
        _zhifuFangShiBJ = 0;
        _btnAry = [[NSMutableArray alloc]init];
        [self initView];
    }
    
    return self;

}

-(void)initView{
    NSArray * zhiFuFangShiAry ;
    
        if([WXApi isWXAppInstalled]){//检测是否安装微信
            if (_weiXinZhuangTai == 1) {
                zhiFuFangShiAry = @[@"支付宝支付",@"FTP积分支付"];
            }else{
                zhiFuFangShiAry = @[@"支付宝支付",@"FTP积分支付",@"微信支付",];
            }
        }else{
            zhiFuFangShiAry = @[@"支付宝支付",@"FTP积分支付"];
        }
  

    NSArray *tuBiaoAry = @[@"支付宝",@"余额",@"微信支付",];
    
    for (int i= 0; i < zhiFuFangShiAry.count; i++) {
        
        ZhiFuViewFangShiBtn *zhiFuFangShiBtn = [[ZhiFuViewFangShiBtn alloc]initWithFrame:CGRectMake(0, i * _height, KScreenWidth, _height)];
        
        [self addSubview:zhiFuFangShiBtn];
        [zhiFuFangShiBtn addTarget:self action:@selector(zhiFuFangSHi:) forControlEvents:UIControlEventTouchUpInside];
        zhiFuFangShiBtn.tag = i;
       
       zhiFuFangShiBtn.tuBiaoImage.image = [UIImage imageNamed:[tuBiaoAry objectAtIndex:i]];
        
        zhiFuFangShiBtn.namelabel.text = [zhiFuFangShiAry objectAtIndex:i];
        if ([[zhiFuFangShiAry objectAtIndex:i] isEqual:@"FTP积分支付"]) {
            zhiFuFangShiBtn.tipLab.text = @"推荐优先使用余额支付";
        }else if ([[zhiFuFangShiAry objectAtIndex:i] isEqual:@"支付宝支付"]){
            zhiFuFangShiBtn.tipLab.text = @"推荐有支付宝账号的用户使用";
        }else if ([[zhiFuFangShiAry objectAtIndex:i] isEqual:@"微信支付"]){
            zhiFuFangShiBtn.tipLab.text = @"推荐安装5.0版本以上的用户使用";
        }
        
        [_btnAry addObject:zhiFuFangShiBtn];
        if (i == 0) {
             zhiFuFangShiBtn.gouXuanImage.image = [UIImage imageNamed:@"对勾"];
        }else{
             zhiFuFangShiBtn.gouXuanImage.image = [UIImage imageNamed:@"圆圈"];
        }
        
//        UILabel *fenGe = [[UILabel alloc]initWithFrame:CGRectMake(0, _height - 1, KreenWidth, 1)];
//        fenGe.backgroundColor = LIGHTGRAYBACKCOLOR;
//        [zhiFuFangShiBtn addSubview:fenGe];
        
    }
    
//    _myYuEView = [[YEShiYongView alloc]initWithFrame:CGRectMake(0, 10 * _kscH, KreenWidth, 50)];
//   
//    [self addSubview:_myYuEView];
}

-(void)zhiFuFangSHi:(ZhiFuViewFangShiBtn *)sender{
    
    _zhifuFangShiBJ = (int)sender.tag;
    for (ZhiFuViewFangShiBtn *btn in _btnAry) {
        btn.gouXuanImage.image = [UIImage imageNamed:@"圆圈"];
    }
    
    sender.gouXuanImage.image = [UIImage imageNamed:@"对勾"];
    
    
}
/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
